package com.doushu.dispatch.controller;

import com.doushu.dispatch.common.dto.ResultDto;
import com.doushu.dispatch.service.DataUpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(description = "数据上传controller")
public class DataUpController {

    @Autowired
    private DataUpService dataUpService;

    @RequestMapping(value = "/carDataUp", method = RequestMethod.POST)
    @ApiOperation(value = "直通车关键词数据上传", httpMethod = "POST")
    public ResultDto carDataUp(
            @ApiParam(name = "data",value="上传的数据",required = true)@RequestParam String data,
            @ApiParam(name = "shopId",value="店铺id",required = true,example = "0")@RequestParam Long shopId,
            @ApiParam(name = "terminal",value="终端类型",required = true,example = "0")@RequestParam Integer terminal,
            @ApiParam(name = "datatime",value="数据日期",required = true)@RequestParam String datatime) {
        return dataUpService.carDataUp(data, shopId, terminal, datatime);
    }

    @RequestMapping(value = "/itemsEffectDetailUp", method = RequestMethod.POST)
    @ApiOperation(value = "商品列表数据上传", httpMethod = "POST")
    public ResultDto itemsEffectDetailUp(
            @ApiParam(name = "data",value="上传的数据",required = true)@RequestParam String data,
            @ApiParam(name = "shopId",value="店铺id",required = true,example = "0")@RequestParam Long shopId) {
        return dataUpService.itemsEffectDetailUp(data, shopId);
    }

    @RequestMapping(value = "/listFlowFromUp", method = RequestMethod.POST)
    @ApiOperation(value = "商品来源数据上传", httpMethod = "POST")
    public ResultDto listFlowFromUp(
            @ApiParam(name = "data",value="上传的数据",required = true)@RequestParam String data,
            @ApiParam(name = "shopId",value="店铺id",required = true,example = "0")@RequestParam Long shopId,
            @ApiParam(name = "itemId",value="商品id",required = true,example = "0")@RequestParam Long itemId,
            @ApiParam(name = "terminal",value="终端类型",required = true,example = "0")@RequestParam Integer terminal,
            @ApiParam(name = "datatime",value="数据日期",required = true)@RequestParam String datatime) {
        return dataUpService.listFlowFromUp(data, shopId, itemId, terminal, datatime);
    }

    @RequestMapping(value = "/itemKeywordsUp", method = RequestMethod.POST)
    @ApiOperation(value = "关键词效果分析数据上传", httpMethod = "POST")
    public ResultDto itemKeywordsUp(
            @ApiParam(name = "data",value="上传的数据",required = true)@RequestParam String data,
            @ApiParam(name = "shopId",value="店铺id",required = true,example = "0")@RequestParam Long shopId,
            @ApiParam(name = "itemId",value="商品id",required = true,example = "0")@RequestParam Long itemId,
            @ApiParam(name = "terminal",value="终端类型",required = true,example = "0")@RequestParam Integer terminal,
            @ApiParam(name = "datatime",value="数据日期",required = true)@RequestParam String datatime) {
        return dataUpService.itemKeywordsUp(data, shopId, itemId, terminal, datatime);
    }

    @RequestMapping(value = "/creativeUp", method = RequestMethod.POST)
    @ApiOperation(value = "创意数据上传", httpMethod = "POST")
    public ResultDto creativeUp(
            @ApiParam(name = "shopId",value="店铺id",required = true,example = "0")@RequestParam Long shopId,
            @ApiParam(name = "campaignId",value="推广计划id",required = true,example = "0")@RequestParam Integer campaignId,
            @ApiParam(name = "adGroupId",value="商品id",required = true,example = "0")@RequestParam Integer adGroupId,
            @ApiParam(name = "datatime",value="数据日期",required = true)@RequestParam String datatime,
            @ApiParam(name = "trafficType",value="终端+来源类型",required = true)@RequestParam String trafficType,
            @ApiParam(name = "data",value="上传的数据",required = true)@RequestParam String data) {
        return dataUpService.creativeUp(shopId, campaignId, adGroupId, datatime, trafficType, data);
    }
}